# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=nbd
pkgver=3.26.1
pkgrel=0
pkgdesc="Tools for network block devices"
url="https://nbd.sourceforge.io/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	bison
	glib-dev
	gnutls-dev
	libnl3-dev
	linux-headers
	zlib-dev
	"
# Disable -doc, requires docbook2man
subpackages="$pkgname-client $pkgname-openrc"
source="https://github.com/NetworkBlockDevice/nbd/releases/download/nbd-$pkgver/nbd-$pkgver.tar.xz
	nbd-server.initd
	gcc14-nbd-client-fix-build.patch
	skip-manpages-systemd.patch
	"

# secfixes:
#   3.24-r0:
#     - CVE-2022-26495
#     - CVE-2022-26496

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-lfs \
		--enable-syslog
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/nbd-server.initd \
		"$pkgdir"/etc/init.d/nbd-server
	mkdir -p "$pkgdir"/etc/nbd-server
}

client() {
	pkgdesc="$pkgdesc (client)"
	amove usr/sbin/nbd-client
}

sha512sums="
ceb1df5b4f28805f3aeccd5a0c8bd7c04e1eac461ef4d93f595e2b19b04039acecd587be88c457a9d9187b2366f57faa38757fb8fd15ab0ec53634b841e40bf0  nbd-3.26.1.tar.xz
7012adb1d822454b29d1c75cdeaab9dfa2bf0e41c058509428227953b1e555b76c1802a78e66d8fa3fc2ada932cfe265e80c90fa9dbddd544c81b1411c8ab4b4  nbd-server.initd
eebb499e6974ef1abf6fdc34bed4ec3ec52409410390abaabd9938380a9c60938755bdb6feb1b6af78316474f0187120bd271c032f53151919b045caaeb1f850  gcc14-nbd-client-fix-build.patch
20a69c0bf247b232a40a1d76f13addd8887b4cb38763ed64ff12b403ca1a882768a55b2cca1d0b200559537a95add319029f22ce3f5960d15407650ac393061b  skip-manpages-systemd.patch
"
